package com.sky.zzh.today;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class CalendarUtil {

  public static String getPrevious(int year, int month, int day) {
    Date date = new Date();// 取时间
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.MONTH, month - 1);
    calendar.set(Calendar.DAY_OF_MONTH, day);
    calendar.add(calendar.DATE, -1);// 把日期往后增加一天.整数往后推,负数往前移动
    date = calendar.getTime(); // 这个时间就是日期往后推一天的结果
    SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
    String dateString = formatter.format(date);
    return dateString;
  }

}
